/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.xtd.model.employment;

import com.xtd.util.PayrollCalculatorEnum;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Lu Yuanbin
 */
@Entity
@Table(name = "department_post")
public class DepartmentPost implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Column(name = "name")
    private String name;
    @Column(name = "post")
    private String post;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "departmentPost")
    private Collection<Employee> emloyeeCollection;
    @Column(name = "payroll_calculator")
    @Enumerated(EnumType.STRING)
    private PayrollCalculatorEnum payrollCalculator;
    @Column(name = "active")
    private boolean active;

    public DepartmentPost() {
    }

    public boolean isNew() {
        if(id == null) {
            return true;
        } else {
            return false;
        }
    }
    public DepartmentPost(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPost() {
        return post;
    }

    public void setPost(String post) {
        this.post = post;
    }

    public Collection<Employee> getEmloyeeCollection() {
        return emloyeeCollection;
    }

    public void setEmloyeeCollection(Collection<Employee> emloyeeCollection) {
        this.emloyeeCollection = emloyeeCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof DepartmentPost)) {
            return false;
        }
        DepartmentPost other = (DepartmentPost) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return name + "[" + post + "]";
    }

    /**
     * @return the payrollCalculator
     */
    public PayrollCalculatorEnum getPayrollCalculator() {
        return payrollCalculator;
    }

    /**
     * @param payrollCalculator the payrollCalculator to set
     */
    public void setPayrollCalculator(PayrollCalculatorEnum payrollCalculator) {
        this.payrollCalculator = payrollCalculator;
    }

    public String getDepartmentPostInfo() {
        return this.toString();
    }

    /**


    /**
     * @param additionalRoyaltyPercentage the additionalRoyaltyPercentage to set
     */
    /**
     * @return the active
     */
    public boolean isActive() {
        return active;
    }

    /**
     * @param active the active to set
     */
    public void setActive(boolean active) {
        this.active = active;
    }
}
